package com.ted.zookeeperMap;

import org.apache.log4j.Logger;
import org.junit.Test;

/**
 * User: guohaozhao (guohaozhao@sohu-inc.com)
 * Date: 13-8-8 16:41
 */
public class ZookeeperOperatorTest2 {

    private static Logger logger = Logger.getLogger(ZookeeperOperatorTest2.class);

    public static  void test() throws Exception {

        FunctionUtil.ByteArrayToString byteArrayToString = new FunctionUtil.ByteArrayToString();
        FunctionUtil.StringToByteArray stringToByteArray = new FunctionUtil.StringToByteArray();

        ZookeeperClient zookeeperClient = new ZookeeperClient("10.20.16.157:35001", 6000, null, null);

        final ZookeeperMap<String> zkMap = ZookeeperMap.createRigidZookeeperMap(zookeeperClient, "/zookeeper", byteArrayToString);
        final ZookeeperOperator<String> zkOpe = new ZookeeperOperator<String>(zookeeperClient, "/zookeeper", stringToByteArray, false);

      
         Thread thread2 = new Thread(){
             public void run(){
             	while (true) {
             		   System.out.println("read----"+zkMap.delegate());
             			try {
							Thread.sleep(5000);
						} catch (InterruptedException e) {
							// TODO Auto-generated catch block
							e.printStackTrace();
						}
             	}
              
             }
          };
          thread2.start();
    }
    
    public static void main(String[] args) {
    	try {
			test();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
